package com.weipai.education.controller;

import com.weipai.education.model.api.Response;
import com.weipai.education.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/12 10:55
 */
@RestController
@Validated
public class LoginController {
    
    @Autowired
    private LoginService loginService;

    /**
     * 登录
     * @param mobile
     * @param password
     * @return
     */
    @RequestMapping(value = "/login/login", method = RequestMethod.GET)
    public Response login(@NotBlank(message = "登录名不能为空") String mobile, 
                          @NotBlank(message = "密码不能为空") String password){
        return loginService.login(mobile, password);
    }

    /**
     * 退出
     * @return
     */
    @RequestMapping(value = "/login/loginOut", method = RequestMethod.GET)
    public Response loginOut() {
        return loginService.loginOut();
    }
}
